package com.zhuiYun.project.api.dynamicAudit.controller;
import com.zhuiYun.project.annotation.OptLog;
import com.zhuiYun.project.api.dynamicAudit.entity.DynamicAudit;
import com.zhuiYun.project.api.dynamicAudit.service.DynamicAuditService;
import com.zhuiYun.project.common.controller.BaseController;
import com.zhuiYun.project.common.response.CommonConstants;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import com.zhuiYun.project.util.pageUtil.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @author mao
 * @date 4.5 14:01
 */
@RestController
@Api(tags = "动态审核")
@RequestMapping("/DynamicAudit")
@Slf4j
@CrossOrigin
public class DynamicAuditController extends BaseController {

    @Autowired
    DynamicAuditService dynamicAuditService;

    /**
     * @Description: TODO 动态查询方法 user表nickNanme dynamic_comment表 comment_time image_id dynamic_content
     * param pageRequest
     * @param nickName
     * @return: com.zhuiYun.project.common.response.CommonResult
     * @Author: mao
     * @Date: 2023/4/7 9:47
     */
    @GetMapping("/DynamicAuditList")
    @ApiOperation(value = "动态的查询方法")
    @OptLog(modular = "diy动态管理", type = CommonConstants.SELECT, describe = "待审批动态查询")
    public CommonResult DynamicAuditList( PageRequest pageRequest, String nickName){
        PageResult pageResult = dynamicAuditService.getDyamic(pageRequest,nickName);
        log.info("动态查询");
        return CommonResult.ok(pageResult);
    }
    /**
     * @Description:审核状态改为1
     * @param id
     * @return: com.zhuiYun.project.common.response.CommonResult
     * @Author: mao
     * @Date: 2023/4/7 11:31
     */
    @DeleteMapping("/UpdateDynamicAuditList/{id}")
    @ApiOperation(value = "修改审核标识 审批成功")
    @OptLog(modular = "diy动态管理", type = CommonConstants.ADD, describe = "审批通过")
    public CommonResult UpdateDynamicAuditList(@PathVariable("id") int id){
        int i = dynamicAuditService.UpdateDynamicAuditList(id);
        return CommonResult.ok(i);
    }
    /**
     * @Description:审核状态改为2
     * @param id
     * @return: com.zhuiYun.project.common.response.CommonResult
     * @Author: mao
     * @Date: 2023/4/7 11:31
     */
    @DeleteMapping("/UpdateDynamicAuditListTwo/{id}")
    @ApiOperation(value = "修改审核标识 审批成功")
    @OptLog(modular = "diy动态管理", type = CommonConstants.ADD, describe = "审批驳回")
    public CommonResult UpdateDynamicAuditListTwo(@PathVariable("id") int id){
        int i = dynamicAuditService.UpdateDynamicAuditListTwo(id);
        return CommonResult.ok(i);
    }
}
